/*
 * Class:PHeader
 * 
 * Description: This class represent the header of the calendar.
 * 
 * Version: 2.0 - Mathieu Canuel - 26-11-2011
 * 		Initial implementation
 * 
 */
package calendarInterface2;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

@SuppressWarnings("serial")
public class PHeader extends JPanel {
	JPanel pTitle;
	JPanel pMenu;
	JLabel lHeaderMessage;
	JButton bMonthView;
	JButton bWeekView;
	JButton bDayView;
	JButton bPrint;

	public PHeader() {
		super();
		build();
	}
	
	public void build(){
		setLayout(new BorderLayout());
		setSize(new Dimension(1024,200));
		pTitle = new JPanel();
		pTitle.setSize(new Dimension(800,200));
		lHeaderMessage = new JLabel();
		Font font = new Font("Arial",Font.BOLD,20);
		lHeaderMessage.setFont(font);
		pTitle.add(lHeaderMessage, BorderLayout.WEST);
		pMenu = new JPanel();
		pMenu.setSize(new Dimension(224,200));
		bMonthView = new JButton("Month");
		bMonthView.addActionListener(new ActionMonthView());
		bWeekView = new JButton("Week");
		bWeekView.addActionListener(new ActionWeekView());
		bDayView = new JButton("Day");
		bDayView.addActionListener(new ActionDayView());
		bPrint = new JButton("Print");
		bPrint.addActionListener(new ActionPrint());
		pMenu.add(bMonthView, BorderLayout.EAST);
		pMenu.add(bWeekView, BorderLayout.EAST);
		pMenu.add(bDayView, BorderLayout.EAST);
		pMenu.add(bPrint, BorderLayout.EAST);
		this.add(pTitle,BorderLayout.WEST);
		this.add(pMenu, BorderLayout.EAST);
	}
	
	public void setHeaderMessage(String sMessage) {
		lHeaderMessage.setText(sMessage);
	}
	
	public String getHeaderMessage() {
		return lHeaderMessage.getText();
	}
	
	public class ActionMonthView implements ActionListener{
		public void actionPerformed(ActionEvent e) {
			CalendarInterface.showMonthView(CalendarInterface.getSideCalDate());
		}
	}
	
	public class ActionDayView implements ActionListener{
		public void actionPerformed(ActionEvent e) {
			CalendarInterface.showDayView(CalendarInterface.getSideCalDate());
		}
	}	
	
	public class ActionWeekView implements ActionListener{
		public void actionPerformed(ActionEvent e) {
			CalendarInterface.showWeekView(CalendarInterface.getSideCalDate());
		}
	}
	
	public class ActionPrint implements ActionListener{
		public void actionPerformed(ActionEvent e) {
			CalendarInterface.print();
		}
	}
}
